package com.canbot.u05.view;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.canbot.u05.R;

/**
 * 输入框对话框
 */

public class EditTextDialog extends Dialog {

        private EditText editText;

        private Button positiveButton, negativeButton;

        private TextView title;

        public EditTextDialog(Context context) {
                super(context, R.style.MyDialogStyle);
                setCustomDialog();
        }

        private void setCustomDialog() {
                View mView = LayoutInflater.from(getContext()).inflate(R.layout.layout_dialog_edit, null);
                title = (TextView) mView.findViewById(R.id.tv_dialogtitle);
                editText = (EditText) mView.findViewById(R.id.et_question);
                editText.setTextSize(20);
                positiveButton = (Button) mView.findViewById(R.id.counsel_dialog_reconnection);
                negativeButton = (Button) mView.findViewById(R.id.counsel_dialog_cancel);
                super.setContentView(mView);


        }

        public void setTitle(String text) {
                title.setText(text);
        }

        public EditText getEditText() {
                return editText;
        }

        @Override
        public void setContentView(int layoutResID) {
        }

        @Override
        public void setContentView(View view, ViewGroup.LayoutParams params) {
        }

        @Override
        public void setContentView(View view) {
        }


        /**
         * 确定键监听器
         *
         * @param listener
         */
        public void setOnPositiveListener(View.OnClickListener listener) {
                positiveButton.setOnClickListener(listener);
        }

        /**
         * 取消键监听器
         *
         * @param listener
         */
        public void setOnNegativeListener(View.OnClickListener listener) {
                negativeButton.setOnClickListener(listener);
        }

}
